package com.lxf.complayTest.utils;

/**
 * Created by Luoxingfa on 2021/9/22 0022 14:54
 *
 * {
 *   "code": 0,
 *   "msg": "",
 *   "count": 1000,
 *   "data": [{}, {}]
 * }
 */
public class ResultVo {

    /*
    * 状态码：必须为零（layui）
    * */
    private int code;
    /*
    * 返回的提示信息
    * */
    private String msg;
    /*
    * 数量，这是为了做分页而准备的
    * */
    private int count;
    /*
    * 返回的数据
    * */
    private Object data;

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    /*
    * code成功时执行的方法
    *
    * */
      public static ResultVo getSuccessVo(String msg,Object data){
            ResultVo resoultVo = new ResultVo();
            resoultVo.setMsg(msg);
            resoultVo.setData(data);
            return resoultVo;
      }

      /*
      * 查询失败会有返回提示，但是没有数据
      * */
      public static ResultVo getSuccessVo(String msg){
         return ResultVo.getSuccessVo(msg,null);
      }
    /*
    * code失败时执行的方法
    *
    * */
     public static ResultVo getFailVo(String msg){
          ResultVo resoultVo = new ResultVo();
          resoultVo.setMsg(msg);
          resoultVo.setCount(500);
          return resoultVo;
     }
  }